#pragma once
#include <iostream>

using namespace std;
#include <stdio.h>
#include <tchar.h>
#include<opencv2/core/core.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<opencv2/opencv.hpp>
#include<opencv2/opencv_modules.hpp>

using namespace std;
using namespace cv;

/*class Base64Tochar:base64编码/解码*/
class Base64Tochar{
public:
    string base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len); //char转base64
    string base64_decode(string const& encoded_string);  //base64转char
    static inline bool is_base64(unsigned char c) {
        return (isalnum(c) || (c == '+') || (c == '/'));
    }

};
class CImageProcess{
public:
    void AdaptiveThreshold(unsigned char* input, unsigned char*& bin, int width, int height, int S, int T); //图像二值化函数
    void UnmaskSharp(Mat& srcImage, Mat& dstImage, Size& size, int k);
    void background_remove(Mat& srcImage, Mat& dstImage, int size); //去除图像背景
    void ComputeAngle(const Point& leftpeak, const Point& rightpeak, double& angle); //计算倾斜角度
    void deskew(Mat& srcImage, double angle); //图片旋转函数
    Mat getImageData(string imagedata); //获取图片数据
    void encode_image(Mat& srcImage, string& imagedata_base64);  //将Mat转化成jpg
    bool image_process(string& src_image_data_base64, Point left_top_point, Point right_top_point, string result_image_data_base64);
    bool image_process(string& src_image_path, string& result_image_path);
    void RemoveSmallRegion(Mat& Src, Mat& Dst, int AreaLimit, int CheckMode, int NeihborMode);

private:
    Base64Tochar m_base642char; //声明类Base64Tochar的对象
};
